#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (auto& x: arr) cin >> x;
  do {
    int back = arr.back();
    arr.erase(arr.begin() + n - 1);
    arr.insert(arr.begin(), back);
    for (auto& x: arr) cout << x << ' ';
    cout << endl;
  } while (arr.back() != n);
}